﻿using System;
using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace GLog.UnitTest
{
    [TestClass]
    public class UnitTest1
    {
        // TODO: Mock the log and make unit test really unit tests.
        
        [TestMethod]
        [TestCategory("Integration")]
        public void TestLogE2E()
        {
            // Write log to both BufferedTextFileLog & ConsoleLog
            ILog consoleLog = new ConsoleLog();
            ILog log = new BufferedTextFileLog("Test.log", consoleLog);
            
            log.LogMessage("Hello M.");
            log.LogWarning("Hello W.");
            log.LogError("Hello E.");
            log.WriteLog();
        }

        [TestMethod]
        [TestCategory("Integration")]
        public void TestLogE2EMessageOnly()
        {
            ILog log = new BufferedTextFileLog("TestMessageOnly.log", displayLevel: LogLevel.Message);
            log.LogMessage("Hello M.");
            log.LogWarning("Hello W.");
            log.LogError("Hello E.");
            log.WriteLog();
        }

        [TestMethod]
        [TestCategory("Integration")]
        public void TestLogE2EWarningAndError()
        {
            ILog log = new BufferedTextFileLog("TestWarningAndErrorOnly.log", displayLevel: LogLevel.Warning | LogLevel.Error);
            log.LogMessage("Hello M.");
            log.LogWarning("Hello W.");
            log.LogError("Hello E.");
            log.WriteLog();
        }


        [TestMethod]
        [TestCategory("Integration")]
        public void TestLogE2ECSV()
        {
            ILog log = new BufferedCSVFileLog("UnitTest.csv");
            log.LogHeader("Hello Header");
            log.LogMessage("Hello M.");
            log.LogWarning("Hello W.");
            log.LogError("Hello E.");
            log.WriteLog();
        }
    }
}
